package neu.soft.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Objects;

@Getter
public enum OrderType implements BaseEnum{
   NORMAL_ORDER(0,"普通订单"),
   RETURN_ORDER(1,"退货单"),
    EXCHANGE_ORDER(2,"换货单"),
    LACK_ORDER(3,"缺货单");


    @EnumValue
    private final int code;
    @JsonValue
    private final String value;

    OrderType(int code, String value) {
        this.code = code;
        this.value = value;
    }


    //必须重写toString
    @Override
    public String toString() {
        return this.value;
    }

    @JsonCreator
    public static OrderType getItem(String value){
        for(OrderType item : values()){
            if(Objects.equals(item.getValue(), value)){
                return item;
            }
        }
        return null;
    }

    /**
     * @return
     */
    @Override
    public int getCode() {
        return code;
    }

    /**
     * @return
     */
    @Override
    public String getValue() {
        return this.value;
    }

}
